package com.dfiles.utils.dialog;

import android.app.AlertDialog;
import android.app.Dialog;
import android.app.ProgressDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ListAdapter;
import android.widget.TextView;
import android.widget.Toast;

public class DialogUtil {
	public static final int CANCEL = -2;
	public static final int YES = -1;
	public static Toast toast;

	public static Dialog showDialog(Context paramContext, int paramInt, String paramString1, String paramString2, DialogCallBack paramDialogCallBack) {
		return showDialog(paramContext, paramString1, paramString2, paramDialogCallBack);
	}

	public static Dialog showDialog(Context paramContext, String paramString1, String paramString2, final DialogCallBack dialogCallBack) {
		AlertDialog.Builder localBuilder = new AlertDialog.Builder(paramContext).setTitle(paramString1).setMessage(paramString2).setNegativeButton("确定", new DialogInterface.OnClickListener() {
			public void onClick(DialogInterface paramAnonymousDialogInterface, int paramAnonymousInt) {
				if (dialogCallBack != null) {
					dialogCallBack.onClick(YES);
				}
			}
		});
		if (dialogCallBack != null) {
			localBuilder.setPositiveButton("取消", new DialogInterface.OnClickListener() {
				public void onClick(DialogInterface paramAnonymousDialogInterface, int paramAnonymousInt) {
					if (dialogCallBack != null) {
						dialogCallBack.onClick(CANCEL);
					}
				}
			});
		}
		return localBuilder.show();
	}

	public static Dialog showItemDialog(Context paramContext, String paramString, CharSequence[] paramArrayOfCharSequence, final DialogCallBack callback) {
		return new AlertDialog.Builder(paramContext).setTitle(paramString).setItems(paramArrayOfCharSequence, new DialogInterface.OnClickListener() {
			public void onClick(DialogInterface paramAnonymousDialogInterface, int which) {
				if (callback != null) {
					callback.onClick(which);
				}
			}
		}).show();
	}

	public static Dialog showProgressDialog(Context paramContext) {
		return showProgressDialog(paramContext, "");
	}

	public static Dialog showProgressDialog(Context paramContext, String paramString) {
		ProgressDialog localProgressDialog = new ProgressDialog(paramContext);
		localProgressDialog.setMessage(paramString);
		localProgressDialog.show();
		localProgressDialog.setCancelable(true);
		return localProgressDialog;
	}

	public static Dialog showProgressDialog(Context paramContext, String paramString1, String paramString2) {
		ProgressDialog localProgressDialog = new ProgressDialog(paramContext);
		localProgressDialog.setTitle(paramString1);
		localProgressDialog.setMessage(paramString2);
		localProgressDialog.show();
		localProgressDialog.setCancelable(true);
		return localProgressDialog;
	}

	public static void showToastLong(Context paramContext, String paramString) {
		if (toast == null) {
			toast = new Toast(paramContext);
		}
		toast.setDuration(1);
		TextView localTextView = new TextView(paramContext);
		localTextView.setText(paramString);
		localTextView.setTextColor(-1);
		localTextView.setPadding(15, 10, 15, 10);
		localTextView.setBackgroundResource(17301654);
		toast.setView(localTextView);
		toast.show();
	}

	public static void showToastShort(Context paramContext, String paramString) {
		if (toast == null) {
			toast = new Toast(paramContext);
		}
		toast.setDuration(0);
		TextView localTextView = new TextView(paramContext);
		localTextView.setText(paramString);
		localTextView.setTextColor(-1);
		localTextView.setPadding(15, 10, 15, 10);
		localTextView.setBackgroundResource(17301654);
		toast.setView(localTextView);
		toast.show();
	}

	class DialogOnItemClickListener implements AdapterView.OnItemClickListener {
		Dialog dialog;

		DialogOnItemClickListener() {
		}

		public void onItemClick(AdapterView<?> paramAdapterView, View paramView, int paramInt, long paramLong) {
		}

		public void setDialog(Dialog paramDialog) {
			this.dialog = paramDialog;
		}
	}
}
